//package com.haydn.practice.restfulweb.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.provisioning.InMemoryUserDetailsManager;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
///**
// * @Author haydn
// * @create 2020/9/1 23:08
// *
// * 为理解springSecurity的工作原理
// * 创建Spring Security的首个配置类，测试用
// *
// * @Configuration表明这是一个配置类，类似旧有的xml配置文件
// * 在SpringSecurity 5.0 之后，新增了很多的加密方法，所以才会有控制台中的如下报错：
// * java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"
// *
// */
//@Configuration
//@EnableWebSecurity
//public class WebSecurityConfig implements WebMvcConfigurer {
//
//    @Bean
//    public UserDetailsService userDetailService(){
//        InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
//        manager.createUser(User.withUsername("Fire")
//                .password(new BCryptPasswordEncoder().encode("Ace")).roles("").build());
//        manager.createUser(User.withUsername("Sea")
//                .password("Dn").roles("").build());
//
//        //????????????
//        AuthenticationManagerBuilder auth = new AuthenticationManagerBuilder();
//        auth.inMemoryAuthentication().passwordEncoder(new BCryptPasswordEncoder()).withUser("user1").password(new BCryptPasswordEncoder().encode("123456")).roles("USER");
//        return manager;
//
//
//    }
//}
